using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Yunwei.Domain.Models.Mapping
{
    public class UserMap : EntityTypeConfiguration<User>
    {
        public UserMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NickName)
                .HasMaxLength(50);

            this.Property(t => t.RealName)
                .HasMaxLength(50);

            this.Property(t => t.Email)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Password)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Phone)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.Avatar)
                .HasMaxLength(200);

            this.Property(t => t.LoginIP)
                .HasMaxLength(50);

            this.Property(t => t.Role)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("User");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.NickName).HasColumnName("NickName");
            this.Property(t => t.RealName).HasColumnName("RealName");
            this.Property(t => t.Sex).HasColumnName("Sex");
            this.Property(t => t.Email).HasColumnName("Email");
            this.Property(t => t.Password).HasColumnName("Password");
            this.Property(t => t.Phone).HasColumnName("Phone");
            this.Property(t => t.Avatar).HasColumnName("Avatar");
            this.Property(t => t.Status).HasColumnName("Status");
            this.Property(t => t.RegistTime).HasColumnName("RegistTime");
            this.Property(t => t.LoginTime).HasColumnName("LoginTime");
            this.Property(t => t.LoginIP).HasColumnName("LoginIP");
            this.Property(t => t.VIPLevel).HasColumnName("VIPLevel");
            this.Property(t => t.Role).HasColumnName("Role");
        }
    }
}
